package cn.tannn.ops.message.controller.pojo;

import cn.tannn.jdevelops.annotations.jpa.JpaSelectIgnoreField;
import cn.tannn.jdevelops.annotations.jpa.JpaSelectOperator;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLConnect;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLOperatorWrapper;
import cn.tannn.jdevelops.jpa.request.PagingSorteds;
import cn.tannn.ops.message.constant.WebHookApp;
import cn.tannn.ops.message.constant.WebHookSecretType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;


/**
 * 分页查询webhook
 *
 * @author <a href="https://t.tannn.cn/">tan</a>
 * @version V1.0
 * @date 2024/8/23 上午10:45
 */
@Schema(description = "分页查询webhook")
@ToString
@Getter
@Setter
public class WebHookPage {


    /**
     * 签名类型：
     * @see WebHookSecretType
     */
    @Schema(description = "签名类型")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    WebHookSecretType signType;

    /**
     * webhook地址所属app[钉钉，飞书，企业微信]
     * @see WebHookApp
     */
    @Schema(description = "webhook地址所属app")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.EQ, connect = SQLConnect.AND)
    WebHookApp app;

    /**
     * 分页排序
     */
    @Schema(description = "分页排序")
    @JpaSelectIgnoreField
    @Valid
    private PagingSorteds page;

    public PagingSorteds getPage() {
        if(page == null){
            return new PagingSorteds().fixSort(1,"id");
        }
        return page;
    }
}
